package red.action;

import com.opensymphony.xwork2.Action;
import net.sf.json.JSONObject;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import red.mapper.Textmapper;
import red.model.ArticleModel;
import red.model.LikeModel;
import red.service.TextService2;
import red.service.impl.TextServiceImpl2;
import red.util.BaseAction;
import red.util.Model;


import java.util.List;

public class TextAction2 extends BaseAction {



    private JSONObject articleModel;
    private List articleModels;
    private List likeModels;
    @Autowired
    private TextService2 textService2;
    private LikeModel likeModel;


    public LikeModel getlikeModel() {
        return likeModel;
    }
    public void setlikeModel(LikeModel likeModel) {
        this.likeModel = likeModel;
    }


    public JSONObject getArticleModel() {
        return articleModel;
    }
    public void setArticleModel(JSONObject articleModel) {
        this.articleModel = articleModel;
    }


    public List<LikeModel> getLikeModels() {
        return likeModels;
    }
    public void setLikeModels(List<LikeModel> likeModels) {
        this.likeModels = likeModels;
    }


    public List<ArticleModel> getArticleModels() {
        return articleModels;
    }
    public void setArticleModels(List<ArticleModel> articleModels) {
        this.articleModels = articleModels;
    }



    //添加文章
    public String addText() {
        Model model = getParams();
        articleModel = textService2.addText(model);
        return Action.SUCCESS;
    }
    //按ID查询文章
    public String findTextid(){
        Model model = getParams();
        articleModels = textService2.findTextid(model);
        return Action.SUCCESS;
    }
    //点赞量
    public String updatelike_num(){
        Model model = getParams();
        articleModel = textService2.updatelike_num(model);
        return Action.SUCCESS;
    }
    //浏览量
    public String updatepage(){
        Model model = getParams();
        articleModel = textService2.updatepage(model);
        return Action.SUCCESS;
    }
    //审核
    public String updateaudit(){
        Model model = getParams();
        articleModel = textService2.updateaudit(model);
        return Action.SUCCESS;
    }
    //点赞
    public String addlike(){
        Model model = getParams();
        likeModel = textService2.addlike(model);
        return Action.SUCCESS;
    }
    //查看是否点赞
    public String findlike(){
        Model model = getParams();
        likeModels = textService2.findlike(model);
        return Action.SUCCESS;
    }

}
